<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>侦听器</title>
    <script src="scripts/jquery-3.4.1.min.js"></script>
    <script src="scripts/vue.js"></script>
</head>
<body>
    <div id="app">
        <h3>{{msg}}</h3>
        <h4>反向msg:{{reverseMsg}}</h4>
        <ul>
            <li v-for="item,index in arr">{{index+"、"+item}}</li>
        </ul>
    </div>

    <script>
        let app=new Vue({
            el:"#app",
            data:{
                msg:"hello world",
                arr:["小红","小黄","小黑"]

            },
            computed:{
                reverseMsg:{
                    get:function(){
                    //this.msg= this.msg.split("").reverse().join("");
                    return this.msg.split("").reverse().join("");
                    },
                    set:function(value){
                        this.msg=value.split("").reverse().join("");
                    }


                }
            },
            watch:{
                msg:function(val){
                    console.log("监听msg变化过程")
                    console.log(val)
                },
                arr:function(val){
                    this.msg="监听arr数组：";
                    console.log(val)
                }
            }
        })
    </script>
</body>
</html>